﻿using System.Net.Http;
using System.Windows;
using WpfApp1;

namespace VideoApp
{
    public partial class MainWindow : Window
    {
        private List<VideoInfo> videoList; // 用来存储后端传来的视频信息

        public MainWindow()
        {
            InitializeComponent();
            LoadVideoSourcesFromBackend();
        }

        // 从后端获取视频信息
        private async void LoadVideoSourcesFromBackend()
        {
            // 假设后端返回的视频信息 API
            //string apiUrl = "http://your-backend-api.com/getVideoSources";
            //using (HttpClient client = new HttpClient())
            //{
            //    string response = await client.GetStringAsync(apiUrl);
            //    videoList = JsonConvert.DeserializeObject<List<VideoInfo>>(response);
            //}
        }

        // 点击图片1事件
        private void Image1_Click(object sender, RoutedEventArgs e)
        {
            OpenVideoDetails(0); // 打开第一路视频
        }

        // 点击图片2事件
        private void Image2_Click(object sender, RoutedEventArgs e)
        {
            OpenVideoDetails(1); // 打开第二路视频
        }

        // 点击图片3事件
        private void Image3_Click(object sender, RoutedEventArgs e)
        {
            OpenVideoDetails(2); // 打开第三路视频
        }

        // 点击图片4事件
        private void Image4_Click(object sender, RoutedEventArgs e)
        {
            OpenVideoDetails(3); // 打开第四路视频
        }

        // 点击图片5事件
        private void Image5_Click(object sender, RoutedEventArgs e)
        {
            OpenVideoDetails(4); // 打开第五路视频
        }

        // 点击图片6事件
        private void Image6_Click(object sender, RoutedEventArgs e)
        {
            OpenVideoDetails(5); // 打开第六路视频
        }

        // 打开视频详情页面
        private void OpenVideoDetails(int videoIndex)
        {
            
                //VideoInfo selectedVideo = videoList[videoIndex];
                VideoDetailsWindow detailsWindow = new VideoDetailsWindow(videoIndex.ToString(),"","");
                detailsWindow.Show();
            
           
                //MessageBox.Show("视频信息尚未加载或索引无效。");
            
        }
    }

    public class VideoInfo
    {
        public string Title { get; set; }       // 视频标题
        public string VideoUrl { get; set; }    // 视频流 URL
        public string Parameters { get; set; }  // 视频参数（如分辨率、时长等）

        public VideoInfo()
        {

        }
    }

   
}
